﻿using System;
using System.Windows.Forms;
using Eagleshoes.PackingBarcode.PackagingScan;
using Eagleshoes.PackingBarcode.Stock;

namespace Eagleshoes.PackingBarcode
{
    public partial class MainMenuForm : Form
    {
        public MainMenuForm()
        {
            InitializeComponent();
        }

        #region Form Events

        private void MainMenuForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.F1:
                    PackagingScan();
                    break;
                case Keys.F2:
                    StockScan();
                    break;
                case Keys.F3:
                    ShipScan();
                    break;
                case Keys.F10:
                    Close();
                    break;
            }
        }

        private void MenuListView_ItemActivate(object sender, EventArgs e)
        {
            var lv = (ListView) sender;
            if (lv.SelectedIndices.Count <= 0)
            {
                return;
            }
            var item = lv.Items[lv.SelectedIndices[0]];
            var tag = item.Tag as string;
            if (string.IsNullOrEmpty(tag))
            {
                return;
            }
            switch (tag)
            {
                case "1":
                    PackagingScan();
                    break;
                case "2":
                    StockScan();
                    break;
                case "3":
                    ShipScan();
                    break;
                case "10":
                    Close();
                            
                    break;
            }
        }

        #endregion

        #region Methods

        private void PackagingScan()
        {
            var frm = new PackagingScanMenuForm();
            frm.ShowDialog();
        }

        private void StockScan()
        {
            var frm = new StockBarcodeQueryForm();
            frm.ShowDialog();
        }

        private void ShipScan()
        {
            var frm = new Shipping.DeliveryCartonForm();
            frm.ShowDialog();
        }
        #endregion

        private void MainMenuForm_Load(object sender, EventArgs e)
        {
            ControlBox = false;
            WindowState = FormWindowState.Maximized;
        }
    }
}